package service

import (
	"ksd-social-api/commons/page"
	nmodel "ksd-social-api/modules/note/model"
	smodel "ksd-social-api/modules/special/model"
	"ksd-social-api/modules/user/model"
	"ksd-social-api/modules/user/model/context"
	"ksd-social-api/modules/user/model/vo"
	"ksd-social-api/utils"
)

/**
 * vip订单
 * @author feige
 * @date 2023-12-14
 * @version 1.0
 * @desc
 */
func (service *UserCenterService) FindMyUserBuyVipOrderPage(ctx context.UserCenterContext) *page.Page {
	userBuyVipPage, _ := userBuyVipMapper.FindMyUserBuyVipOrderPage(ctx.UserId, ctx.SystemId, ctx.PageNo, ctx.PageSize)
	userBuyVipList := userBuyVipPage.Records.([]model.UserBuyVip)
	if userBuyVipList != nil {
		userBuyVipVos := []vo.UserBuyVipVo{}
		for _, userBuyVip := range userBuyVipList {
			userBuyVipVo := vo.UserBuyVipVo{}
			utils.CopyProperties(&userBuyVipVo, userBuyVip)
			userBuyVipVos = append(userBuyVipVos, userBuyVipVo)
		}
		userBuyVipPage.Records = userBuyVipVos
	}
	return userBuyVipPage
}

/**
 * 小册订单
 * @author feige
 * @date 2023-12-14
 * @version 1.0
 * @desc
 */
func (service *UserCenterService) FindMyNoteOrderPage(ctx context.UserCenterContext) *page.Page {
	userBuyNotePage, _ := userBuyNoteMapper.FindMyNotesOrderPage(ctx.UserId, ctx.ChannelIds, ctx.SystemId, ctx.PageNo, ctx.PageSize)
	userBuyNoteList := userBuyNotePage.Records.([]nmodel.UserBuyNote)
	if userBuyNoteList != nil {
		userBuyNoteVos := []vo.UserBuyNoteVo{}
		for _, userBuyNote := range userBuyNoteList {
			userBuyNoteVo := vo.UserBuyNoteVo{}
			utils.CopyProperties(&userBuyNoteVo, userBuyNote)
			userBuyNoteVos = append(userBuyNoteVos, userBuyNoteVo)
		}
		userBuyNotePage.Records = userBuyNoteVos
	}
	return userBuyNotePage
}

/**
 * 小册订单
 * @author feige
 * @date 2023-12-14
 * @version 1.0
 * @desc
 */
func (service *UserCenterService) FindMySpecialOrderPage(ctx context.UserCenterContext) *page.Page {
	userBuySpecialPage, _ := userBuySpecialMapper.FindMySpecialsOrderPage(ctx.UserId, ctx.SystemId, ctx.PageNo, ctx.PageSize)
	userBuySpecialList := userBuySpecialPage.Records.([]smodel.UserBuySpecial)
	if userBuySpecialList != nil {
		userBuySpecialVos := []vo.UserBuySpecialVo{}
		for _, userBuySpecial := range userBuySpecialList {
			userBuySpecialVo := vo.UserBuySpecialVo{}
			utils.CopyProperties(&userBuySpecialVo, userBuySpecial)
			userBuySpecialVos = append(userBuySpecialVos, userBuySpecialVo)
		}
		userBuySpecialPage.Records = userBuySpecialVos
	}
	return userBuySpecialPage
}

/**
 * 小册订单
 * @author feige
 * @date 2023-12-14
 * @version 1.0
 * @desc
 */
func (service *UserCenterService) FindMySpecialBindOrderPage(ctx context.UserCenterContext) *page.Page {
	userBuySpecialBindPage, _ := userBuySpecialBindMapper.FindMySpecialBindsOrderPage(ctx.UserId, ctx.SystemId, ctx.PageNo, ctx.PageSize)
	userBuySpecialBindList := userBuySpecialBindPage.Records.([]smodel.SpecialBindUserBuy)
	if userBuySpecialBindList != nil {
		userBuySpecialBindVos := []vo.UserBuySpecialBindlVo{}
		for _, userBuySpecialBind := range userBuySpecialBindList {
			userBuySpecialBindVo := vo.UserBuySpecialBindlVo{}
			utils.CopyProperties(&userBuySpecialBindVo, userBuySpecialBind)
			userBuySpecialBindVos = append(userBuySpecialBindVos, userBuySpecialBindVo)
		}
		userBuySpecialBindPage.Records = userBuySpecialBindVos
	}
	return userBuySpecialBindPage
}
